﻿<PageFunction
    x:Class="Milkify.Views.ErrorControl"
    x:TypeArguments="sys:String"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:mcm="clr-namespace:Milkify.ComponentModel"
    Title="Error">
    <Grid>
        <Grid.Resources>
            <mcm:ExceptionHelpUrlConverter x:Key="ExceptionHelpUrlConverter" />
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock
            Grid.Row="0"
            Text="{Binding Title}"
            TextWrapping="Wrap"
            Style="{DynamicResource HeadingTextStyle1}" />
        <TextBlock
            Grid.Row="1"
            TextWrapping="Wrap"
            Text="{Binding Message}"
             Style="{DynamicResource ParagraphTextStyle}" />
        <Expander
            Grid.Row="2"
            Header="Details"
            IsExpanded="False">
            <ListBox
                Name="ListInnerExceptions"
                ItemsSource="{Binding InnerExceptions}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel
                            Width="Auto"
                            HorizontalAlignment="Stretch">
                            <TextBlock 
                                TextWrapping="Wrap"
                                Text="{Binding Message}"
                                Style="{DynamicResource ParagraphTextStyle}" />
                            <TextBlock>
                                <!-- See comments in ErrorControl.xaml.cs -->
                                <!--<Hyperlink 
                                    Command="{Binding DataContext.NavigateToErrorHelpCommand, ElementName=ListInnerExceptions}"
                                    CommandParameter="{Binding}">Error help link</Hyperlink>-->
                                <Hyperlink
                                    Command="ApplicationCommands.Help"
                                    CommandParameter="{Binding}">Error help link</Hyperlink>
                            </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Expander>
        <TextBlock 
            Grid.Row="3" 
            TextWrapping="Wrap"  
            Style="{DynamicResource ParagraphTextStyle}">You can <Hyperlink Command="{x:Static NavigationCommands.BrowseBack}">go back</Hyperlink> 
            and try again, or, if this problem happens again, <Hyperlink Command="{Binding SendBugReportCommand}">send a bug report</Hyperlink>
            to the Milkify support team.</TextBlock>
        <Button
            Grid.Row="4"
            Command="{Binding CopyErrorToClipboardCommand}"
            Content="Copy error to clipboard" />
    </Grid>
</PageFunction>
